package com.example.javatwo.controller.cg.tzl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.example.javatwo.pojo.cg.tzl.PanDian;
import com.example.javatwo.pojo.xs.zqy.PageBean;
import com.example.javatwo.service.cg.tzl.PanDianService;
@Controller

public class PanDianController {
	@Autowired
	private PanDianService pandianservice;
	
	//页面
		@RequestMapping("/pandian")
		public String pandian() throws Exception{
			return "cg/tzl/tzl-pandian";
		}
	
	//分页显示数据
	@ResponseBody
	@RequestMapping(value="/findZhuAll")
	public PageBean findZhuAll(int currentPage){
		Integer count = this.pandianservice.findzong();
		Object pageobj = this.pandianservice.findZhuAll(currentPage);
		PageBean bean = new PageBean(count,currentPage, pageobj);
		return bean;
	}
	
	//新增数据
	@RequestMapping("/InsertPanDianZhu")
	@ResponseBody
	public String Insertzhu(@RequestBody PanDian zhu){
		System.out.println(zhu);
		this.pandianservice.insertzhu(zhu);
		return "保存成功";
	}
	
	//修改
	@ResponseBody
	@RequestMapping("/pandianupdate")
	public String update(@RequestBody PanDian zhu){
		System.out.println(zhu);
		this.pandianservice.update(zhu);
		return "修改成功";
	}
	
	//删除主从
	@ResponseBody
	@RequestMapping(value="/pandiandel",method=RequestMethod.POST)
	public String del(String BillNo){
		System.out.println(BillNo);
		this.pandianservice.del(BillNo);
		return "删除成功";
	}
	
	//审核
	@ResponseBody
	@RequestMapping("/shenhexx")
	public String shenhexx(@RequestBody PanDian data){
		System.out.println(data+"****************");
		pandianservice.shenhe(data);
		return "ok";
	}
	
	//反审核
		@ResponseBody
		@RequestMapping("/unshenhexx")
		public String unshenhexx(@RequestBody PanDian data){
			System.out.println(data+"****************");
			pandianservice.unshenhe(data);
			return "ok";
		}

}
